using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlaneManager : MonoBehaviour
{
    [SerializeField] private GameObject firstGround;
    [SerializeField] private GameObject ground;
    public bool isInit = true;
    public bool playerAxisX = true;
    public static PlaneManager Instance;

    void Awake()
    {
        Instance = this;
    }

    public void GenerateGround()
    {
        if (isInit)
        {
            playerAxisX = true;
            isInit = false;
        }
        else
        {
            playerAxisX = Random.Range(0,100) >= 50;
        }
        var dir = playerAxisX ? Vector3.forward : Vector3.left;
        var go = Instantiate(ground, firstGround.transform.position 
                                     + dir * Random.Range(5,12),Quaternion.identity);
        go.transform.parent = transform;
        firstGround = go;
    }
}
